package com

import com.frame.filter.ParameterVerifyFilter
import com.frame.filter.CorsResponseFilter
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import org.glassfish.jersey.filter.LoggingFilter
import org.glassfish.jersey.jackson.JacksonFeature
import org.glassfish.jersey.server.ResourceConfig
import org.glassfish.jersey.server.mvc.MvcFeature
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature
import org.glassfish.jersey.server.spring.scope.RequestContextFilter
import org.glassfish.jersey.servlet.ServletProperties

/**
 * Created with IntelliJ IDEA.
 * com.myTest.web
 * User: 张斌
 * Date: 2014/7/21
 */
@CompileStatic
@TypeChecked
class MyApplication extends ResourceConfig{


    public MyApplication () {
        packages("com.app", "com.frame")
//        .register(MyObjectMapperProvider.class)  // No need to register this provider if no special configuration is required.
        register(JacksonFeature.class);
        register(RequestContextFilter.class)
//        register(CharsetResponseFilter.class)
        register(ParameterVerifyFilter.class)
        register(CorsResponseFilter.class)


        property(MvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp")
        //property(MvcFeature.ENCODING,"GBK")
        property(ServletProperties.FILTER_STATIC_CONTENT_REGEX,"(/(images|js|css)/?.*)|(/.*\\.jsp)|(/favicon\\.ico)")
        //"(/(images|js|css)/?.*)|(/.*\\.jsp)|(/WEB-INF/.*\\.jsp)|(/favicon\\.ico)"
        register(JspMvcFeature.class);
        register(LoggingFilter.class);
    }

}
